package com.wzy.peopleManagement.commond
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.wzy.peopleManagement.business.UserDeledate;
	import com.wzy.peopleManagement.event.LoginEvent;
	import com.wzy.peopleManagement.model.LoginModel;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;

	public class LoginCommand implements IResponder, ICommand
	{
		private var model : LoginModel = LoginModel.getInstance();
		public function result(data:Object):void
		{
			var objTemp : Object = Object(data.result);
			if(objTemp.SORF == "true") {
				var objValue : Object = objTemp.VALUE;
				model.objUser = objValue;
				model.userName = objValue.userName;
				if(objValue.userName == "admin") {
					model.userType = "admin";
				} else {
					model.userType = "user";
				}
				model.main.goLogin();
			} else {
				Alert.show("用户名或密码输入错误");
			}
		}
		
		public function fault(info:Object):void
		{
			Alert.show("登陆失败，请检查用户名和密码！");
		}
		
		public function execute(event:CairngormEvent):void
		{
			var e : LoginEvent = LoginEvent(event);
			var deleGate : UserDeledate = new UserDeledate(this);
			deleGate.checkLogin(e.userInfoVO); 
		}
	}
}